<template>
  <div>
    <div class="text">姓名：{{loginName}}</div>
    <div class="text">年龄：{{loginAge}}</div>
  <el-table
    :data="tableData" border style="width: 100%">
    <el-table-column
    label="序号"
    type="index"
    width="50">
    </el-table-column>
    <el-table-column
      prop="date"
      label="诊断日期"
      width="180">
    </el-table-column>
    <el-table-column
      prop="result"
      label="诊断结果">
    </el-table-column>
    <el-table-column
      prop="advice"
      label="就诊建议">
    </el-table-column>
    
  </el-table>
  <!-- 分页 -->
  <div class="page">
          <el-pagination
              background
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange"
              :current-page="currentPage"
              :page-size="PageSize"
              :page-sizes="PageSizes"
              layout="total, sizes, prev, pager, next, jumper"
              :total= "totalCount">
          </el-pagination>
      </div>
   </div>
</template>

<script>
import axios from 'axios'  
  export default {
    name:'Admin',
    data() {
      return {
        userToken:'',
        loginName:'',
        loginAge:'',
        tableData: [
          {
            date: '', 
            result:'',
            advice:''
          }
        ],
        currentPage: 1,
        totalCount: 1,
        PageSize: 10,
        PageSizes: [5, 10, 20, 50]
      }
    },
    methods: {
    // 获取信息
    getinfo(){
      localStorage.getItem('userToken')
      console.log('userToken:'+userToken),
      // console.log('123'),
      this.$axios({
          headers: { "Content-Type": "application/json;" },
          method: "get",
          url: "http://"+this.URLhost+"/admin/list/allAdmin",
      })
      .then((res) => {
          if (res.data.code === 0) {
            this.tableData = res.data.data
          } 

      })
    },
    // 刷新页面
    refreshPage() {  
      location.reload();  
    }  ,
    // 分页
    // 每页要显示的条数
    handleSizeChange(val) {
        // 改变每页显示的条数
        this.PageSize = val
        this.currentPage = 1
    },
    handleCurrentChange(val) {
        this.currentPage = val
    }
  },
  mounted() {  
    this.getinfo()
  },
  created() {  
  this.$axios = axios  
  } 
  }
</script>

<style>    
.container > * {  
margin-right: 10px;  
}  
.text {  
padding-top: 15px;
font-weight: bold;  
font-size: 1.5em;
  }
.page {
      float: right;
      height: 50px;
      margin: 15px
  }
</style>